package com.dylan.历史.基础;

/**
 * @author : ankang
 * @date : 2020/3/7 22:22
 * @Description :
 */
public class Builder测试 {

    public static void main(String[] args) {
        Man man = Builder.of(Boy::new)
                .with(Person::setName, "哈哈")
                .with(Boy::setTopValue, new MiddleValue())
                .with(Person::setMiddleValue, new MiddleValue())
                .build();
        System.out.println(man);
    }

    static class Person {
        private String name;
        private TopValue topValue;
        private MiddleValue middleValue;
        private BellowValue bellowValue;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name == null ? null : name.trim();
        }

        public MiddleValue getMiddleValue() {
            return middleValue;
        }

        public void setMiddleValue(MiddleValue middleValue) {
            this.middleValue = middleValue;
        }

        public TopValue getTopValue() {
            return topValue;
        }

        public void setTopValue(TopValue topValue) {
            this.topValue = topValue;
        }

        public BellowValue getBellowValue() {
            return bellowValue;
        }

        public void setBellowValue(BellowValue bellowValue) {
            this.bellowValue = bellowValue;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    ", topValue=" + topValue +
                    ", middleValue=" + middleValue +
                    ", bellowValue=" + bellowValue +
                    '}';
        }
    }

    static class Man extends Person {
    }

    static class Boy extends Man {
    }

    static class TopValue {
    }

    static class MiddleValue extends TopValue {
    }

    static class BellowValue extends MiddleValue {
    }

}
